
	<%@ page import="java.sql.*" %>  

	<%@ page contentType="text/html;charset=UTF-8" language="java" %>  

	<html>  

	<head>  

	    <title>Database Table Example</title>  

	</head>  

	<body>  

	  

	<h1>Database Table Example</h1>  

	  

	<%  

	    try {  

	        // 1. 加载和注册JDBC驱动  

	        Class.forName("org.mariadb.jdbc.Driver");  

	  

	        // 2. 创建数据库连接  

	        String url = "jdbc:mariadb://10.220.140.102:3366/studb14";  

	        String username = "stu14";  

	        String password = "jyw745DJ";  

	        Connection conn = DriverManager.getConnection(url, username, password);  

	  

	        // 3. 创建Statement  

	        Statement stmt = conn.createStatement();  

	  

	        // 4. 执行SQL查询  

	        String sql = "SELECT * FROM your_table";  

	        ResultSet rs = stmt.executeQuery(sql);  

	  

	        // 5. 展示结果  

	        out.println("<table border='1' cellpadding='5'>");  

	        out.println("<tr><th>Column1</th><th>Column2</th><th>Column3</th></tr>"); // 根据你的数据库表结构调整  

	        while (rs.next()) {  

	            out.println("<tr>");  

	            out.println("<td>" + rs.getString("column1") + "</td>");  

	            out.println("<td>" + rs.getString("column2") + "</td>");  

	            out.println("<td>" + rs.getString("column3") + "</td>"); // 根据你的数据库表结构调整  

	            out.println("</tr>");  

	        }  

	        out.println("</table>");  

	  

	        // 6. 关闭资源  

	        rs.close();  

	        stmt.close();  

	        conn.close();  

	  

	    } catch (ClassNotFoundException e) {  

	        out.println("JDBC Driver not found: " + e.getMessage());  

	    } catch (SQLException e) {  

	        out.println("Error connecting to database: " + e.getMessage());  

	    }  

	%>  

	  

	</body>  

	</html>